package ui.layer
{
	import adapter.role.RoleAdapterBase;
	
	import adpter.layer.RoleLayerAdapter;
	
	import flash.display.Bitmap;
	import flash.events.MouseEvent;
	import flash.utils.Dictionary;
	
	import ui.common.DynamicObject;
	
	public class RoleLayerUI extends DynamicObject
	{		
		public function RoleLayerUI()
		{
			super();
			init();
		}
		
		private function init():void
		{
		}
		
		protected function get roleLayerAdapter():RoleLayerAdapter
		{
			return adapter as RoleLayerAdapter;
		}
		
		public function addRole(playerId:uint):void
		{
			var roleBaseAdapter:RoleAdapterBase;
			if(roleLayerAdapter)
			{
				if(roleLayerAdapter.roles[playerId])
				{
					roleBaseAdapter = roleLayerAdapter.roles[playerId] as RoleAdapterBase;
					if(roleBaseAdapter)
					{
						addChild(roleBaseAdapter.roleUI);
					}
				}
			}
		}
		
		override public function update():void
		{
			var roleBaseAdapter:RoleAdapterBase;
			var dic:Dictionary;
			
			if(roleLayerAdapter)
			{
				dic = roleLayerAdapter.roles;
				for each(roleBaseAdapter in dic)
				{
					addChild(roleBaseAdapter.roleUI);
				}
			}
		}
	}
}